﻿using Ookii.Dialogs.Wpf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace test.ViewModels
{
    public class DialogUtil
    {
        public static bool GetDir(string description, out string dir, string rootDir = null)
        {
            dir = null;
            if (VistaFolderBrowserDialog.IsVistaFolderDialogSupported)
            {
                VistaFolderBrowserDialog val = new VistaFolderBrowserDialog();
                val.Description = description;

                val.SelectedPath = rootDir;
                val.Multiselect = (false);
                if (val.ShowDialog() == true)
                {
                    dir = val.SelectedPath;
                    return true;
                }
            }
            else
            {
                FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
                folderBrowserDialog.Description = description;
                if (folderBrowserDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    return false;
                dir = folderBrowserDialog.SelectedPath;
                return true;
            }
            return false;
        }
    }
}
